// requires Prototype
function handleErrorResponse(transport) {
	alert(transport.responseText);
}

// requires Prototype and DHTMLXWindows
function handleErrorResponseWindow(messageText) {
	var win = dhxWins.createWindow("err", 500, 300, 500, 250);
	dhxWins.window("err").setText("Error !");
	win.attachHTMLString(messageText);
}

function successWindow(messageText) {
	var win = dhxWins.createWindow("success", 500, 300, 500, 250);
	dhxWins.window("success").setText("Success !");
	win.attachHTMLString(messageText);
}

// some custom JS Classes (requires prototype)

// Tissue
var Tissue = Class.create({
	initialize : function(object) {
		this.chcID = object.chcID;
		this.tissueTypeID = object.tissueTypeID;
		if (object.masterTissue != null) {
			this.masterTissue = new Tissue(object.masterTissue);
		}
		else
			this.masterTissue = null;
	},

	equals : function(object) {
		if (object.chcID != null && object.tissueTypeID != null) {
			if (object.chcID == this.chcID && object.tissueTypeID == this.tissueTypeID) {
				return true;
			}
		}
		return false;
	},

	hasMasterTissue : function() {
		if (this.masterTissue != null) {
			var mt = this.masterTissue;
			if (mt.chcID != null && mt.tissueTypeID != null)
				return true;
			else
				return false;
		}
		else
			return false;
	},

	setMasterTissue : function(object) {
		if (object != null && object.chcID != null && object.tissueTypeID != null)
			this.masterTissue = object;
	},

	getMasterTissue : function() {
		return this.masterTissue;
	},

	toString : function() {
		if (this.chcID < 10)
			return "CHC00" + this.chcID + this.tissueTypeID;
		else if (this.chcID < 100)
			return "CHC0" + this.chcID + this.tissueTypeID;
		else
			return "CHC" + this.chcID + this.tissueTypeID;
	},

	toHref : function() {
		var link = '<a target=\'_blank\' href=\'mainServlet?appAction=displayTissue&chcID='
				+ this.chcID + '&tissueTypeID=' + this.tissueTypeID + '\'>' + this.toString()
				+ '</a>';
		return link;
	}
});

// TissueType
var TissueType = Class.create({
	initialize : function(tissueTypeID) {
		this.tissueTypeID = tissueTypeID;
	},
	initialize : function(tissueTypeID, tissueTypeDescription) {
		this.tissueTypeID = tissueTypeID;
		this.tissueTypeDescription = tissueTypeDescription;
	},
	equals : function(object) {
		if (object.tissueTypeID != null) {
			if (object.tissueTypeID == this.tissueTypeID) {
				return true;
			}
		}
		return false;
	}
});